package com.younge.spring.repository;

import com.younge.spring.repository.dao.SysRolePermission;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.Set;

public interface SysRolePermissionRepository extends CrudRepository<SysRolePermission, Long> {

    @Modifying
    @Query("DELETE FROM SysRolePermission WHERE roleId = :roleId")
    void deleteAllByRoleId(Long roleId);

    @Modifying
    @Query("SELECT permissionId FROM SysRolePermission WHERE roleId = :roleId")
    Set<Long> findPermissionByRoleId(Long roleId);
}